package com.pzhu.filter;

import com.pzhu.controller.impl.BookControllerImpl;
import com.pzhu.pojo.Book;

import javax.servlet.*;
import java.io.IOException;
import java.util.List;

public class SelectAllBookFilter implements Filter {
    BookControllerImpl bookController = new BookControllerImpl();

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("selectALLBookFilter 执行");
        List<Book> bookList = bookController.selectAllBook();
        servletRequest.setAttribute("bookList", bookList);
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {

    }
}
